home *** CD-ROM | disk | FTP | other *** search
/ Amiga Plus 1999 #2 / Amiga Plus CD - 1999 - No. 2.iso / System-Boost / Grafik / AmiCAD / ARexx_english / ImportText.AmiCAD < prev    next >
Text File  |  1998-06-17  |  2KB  |  72 lines

  1. /* Import a text in a box */
  2. /* $VER: ImportText 1.00e (© R.Florac, 24 mai 1998) */
  3. /* Bug: don't handle the quotes ("), the current scale and placement mode */
  4. /* Only use the left and top borders of the selected box */
  5.  
  6. options results
  7.  
  8. signal on error
  9. signal on syntax
  10.  
  11. 'FIRSTSEL'; obj=result
  12. if obj>0 then do
  13.     'TYPE('obj')'
  14.     if result=22 then do
  15.     'NEXTSEL('obj')'
  16.     if result=0 then do
  17.         'COORDS('obj')';
  18.         PARSE VAR result x0 ',' y0 ',' x1 ',' y1
  19.         xg=minima(x0,x1); xd=maxima(x0,x1)
  20.         yh=minima(y0,y1); yb=maxima(y0,y1)
  21.         'REQFILE("Name of the text file?", "Work:text/ASCII")'; fichier=result
  22.         if fichier ~= "" then do
  23.         if open(file, fichier, 'R') then do
  24.             y0=y0+10
  25.             'SAVEALL(-1)'
  26.             do while y0 < y1
  27.             ligne=readln(file)
  28.             if ligne ~= "" then do
  29.                 ligne=translate(ligne,"        ",'09'x)
  30.                 'WRITE("'ligne'",'x0','y0')'; e=result
  31.                 if e=0 then do
  32.                 'REQUEST("Text placement in line"+CHR(10)+"'ligne'"+CHR(10)+"impossible."+CHR(10)+"Do you want to continue?")'
  33.                 if result=0 then leave
  34.                 end
  35.                 y0=y0+10
  36.             end
  37.             if eof(file) then leave
  38.             end
  39.             close(file)
  40.         end
  41.         end
  42.         exit
  43.     end
  44.     end
  45. end
  46.  
  47. 'MESSAGE("Draw and select a box"+CHR(10)+"where you want to"+CHR(10)+"put the text")'
  48.  
  49. exit
  50.  
  51. minima: procedure
  52.     parse arg v1,v2
  53.     if v1<v2 then return v1
  54.     return v2
  55. end
  56.  
  57. maxima: procedure
  58.     parse arg v1,v2
  59.     if v1>v2 then return v1
  60.     return v2
  61. end
  62.  
  63. /* Traitement des erreurs, interruption du programme */
  64. syntax:
  65. erreur=RC
  66. 'MESSAGE("Script ImportText.AmiCAD"+CHR(10)+"Syntax error"+CHR(10)+"in line 'SIGL'"+CHR(10)+"'errortext(erreur)'")'
  67. exit
  68.  
  69. error:
  70. 'MESSAGE("Script ImportText.AmiCAD"+CHR(10)+"Error in line 'SIGL'")'
  71. exit
  72.